/**
* Copyright 2012 nabla
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*
*/
package com.nabla.wapp.client.ui.form;

import com.google.gwt.user.client.ui.Widget;
import com.nabla.wapp.client.ui.Resource;
import com.smartgwt.client.types.TitleOrientation;


public class FormItem<T extends com.smartgwt.client.widgets.form.fields.FormItem> extends Widget implements IFormItem<T> {

	protected final T		impl;

	protected FormItem(final T impl) {
		this.impl = impl;
		impl.setRequiredMessage(Resource.strings.requiredFieldErrorMessage());
	}

	@Override
	public T getImpl() {
		return impl;
	}

	@Override
	public void setWidth(final String w) {
		impl.setWidth(w);
	}

	@Override
	public void setVisible(boolean visible) {
		impl.setVisible(visible);
	}

	@Override
	public void setHeight(final String h) {
		impl.setHeight(h);
	}

	public void setName(final String name) {
		impl.setName(name);
	}

	public String getName() {
		return impl.getName();
	}

	public void setColSpan(final int colSpan) {
		impl.setColSpan(colSpan);
	}

	public void setStartRow(Boolean startRow) {
		impl.setStartRow(startRow);
	}

	public void setEndRow(Boolean endRow) {
		impl.setEndRow(endRow);
	}

	public void setReadOnly(final boolean readOnly) {
		impl.setCanEdit(!readOnly);
	}

	public boolean isReadOnly() {
		return !impl.getCanEdit();
	}

	public void setRequired(final boolean required) {
		impl.setRequired(required);
	}

	public void setShowTitle(final Boolean showTitle) {
		impl.setShowTitle(showTitle);
	}

	public void setCellStyle(final String style) {
		impl.setCellStyle(style);
	}

	public void setValidateOnChange(boolean validate) {
		impl.setValidateOnChange(validate);
	}

	public void setShouldSaveValue(boolean save) {
		impl.setShouldSaveValue(save);
	}

	public void setDisabled(boolean value) {
		impl.setDisabled(value);
	}

	public void setCanFocus(boolean value) {
		impl.setCanFocus(value);
	}

	public void setTabIndex(Integer index) {
		impl.setTabIndex(index);
	}

	public void setGlobalTabIndex(Integer index) {
		impl.setGlobalTabIndex(index);
	}

	public void setWrapTitle(Boolean value) {
		impl.setWrapTitle(value);
	}

	public void setTitleOrientation(TitleOrientation titleOrientation) {
		impl.setTitleOrientation(titleOrientation);
	}

	public void setRedrawOnChange(Boolean value) {
		impl.setRedrawOnChange(value);
	}

	public void setEnabled(Boolean value) {
		impl.setDisabled(!value);
	}
}
